package com.itbupt.utils;

import com.itbupt.dto.UserDTO;
import com.itbupt.entity.User;

/**
 * @Author BUPT-Dingchang
 * @Create 2024/5/2 17:30
 * ClassName: UserHolder
 * Description: 将用户信息保存到ThreadLocal中
 */
public class UserHolder {

    private static final ThreadLocal<UserDTO> tl = new ThreadLocal<>();

    public static void saveUser(UserDTO user){
        tl.set(user);
    }

    public static UserDTO getUser(){
        return tl.get();
    }

    public static void removeUser(){
        tl.remove();
    }
}
